home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / WMS.CAB / UnicastSink.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  14.7 KB  |  393 lines

  1. ∩╗┐<%@ Language=VBScript CODEPAGE=65001 %>
  2. <!--#include file="include/wmsLocStrings.inc"-->
  3. <!--#include file="include/wmsServerHash.inc"-->
  4. <!--#include file="include/wmsPlugins.inc"-->
  5. <!--#include file="include/wmsHeader.inc"-->
  6. <!--#include file="include/wmsPageBanner.inc"-->
  7. <!--#include file="include/wmsError.inc"-->
  8. <!--#include file="plugin_loading.inc"-->
  9. <%
  10. '+-------------------------------------------------------------------------
  11. '
  12. '  Microsoft Windows Media
  13. '  Copyright (C) Microsoft Corporation. All rights reserved.
  14. '
  15. '  File:       UnicastSink.asp
  16. '
  17. '  Contents:
  18. '
  19. '--------------------------------------------------------------------------
  20.  
  21. ConnectToPlugin
  22. ConnectToPluginAdmin
  23.  
  24. BeginErrorHandling
  25.  
  26. on error resume next
  27.  
  28. Const MIN_PACKET_SIZE = 36
  29. Const MAX_PACKET_SIZE = 65507
  30. Const MAX_PACKET_ENTRY_LEN = 5
  31.  
  32. Dim bError 
  33. Dim g_bUseUDP
  34. Dim g_bUseTCP
  35. Dim g_bUseCustomPacketSize
  36. Dim g_dwCustomPacketSize
  37.  
  38. bError = FALSE
  39.  
  40. '///////////////////////////////////////////////////////////////
  41.  
  42. strPacketSize = Left( GetFormStr( "packetsize" ), MAX_PACKET_ENTRY_LEN )
  43.  
  44. Dim szOp
  45. szOp = GetFormStr( "submit" )
  46. if( 0 < Len( szOp ) ) then
  47.  
  48.     ' use a do-while-false structure to break out upon first error    
  49.     do
  50.         '
  51.         ' Handle TCP checkbox
  52.         '
  53.         if( 0 < Len( GetFormStr( "TCP" ) ) ) then
  54.             g_bUseTCP = TRUE
  55.             if( FALSE = g_objPluginAdmin.TCPEnabled ) then
  56.                 g_objPluginAdmin.TCPEnabled = TRUE
  57.             end if
  58.         else
  59.             g_bUseTCP = FALSE
  60.             if( TRUE = g_objPluginAdmin.TCPEnabled ) then
  61.                 g_objPluginAdmin.TCPEnabled = FALSE
  62.             end if
  63.         end if
  64.  
  65.         '
  66.         ' Handle UDP checkbox
  67.         '
  68.         if( 0 < Len( GetFormStr( "UDP" ) ) ) then
  69.             g_bUseUDP = TRUE
  70.             if( FALSE = g_objPluginAdmin.UDPEnabled ) then
  71.                 g_objPluginAdmin.UDPEnabled = TRUE
  72.             end if
  73.         else
  74.             g_bUseUDP = FALSE
  75.             if( TRUE = g_objPluginAdmin.UDPEnabled ) then
  76.                 g_objPluginAdmin.UDPEnabled = FALSE
  77.             end if
  78.         end if
  79.         
  80.         if( TRUE = g_bUseUDP ) then
  81.             '
  82.             ' Handle IP Packet Size radio buttons
  83.             '
  84.             if( 0 = strcomp( "0", GetFormStr( "packetsize" ), vbTextCompare ) ) then
  85.                 ' use default
  86.                 if( FALSE = g_objPluginAdmin.DefaultPacketSize ) then
  87.                     g_objPluginAdmin.DefaultPacketSize = TRUE
  88.                 end if
  89.             else
  90.                 ' use custom
  91.                 strPacketSize = GetFormStr( "customPacketSize" )
  92.                 g_dwCustomPacketSize = CDbl( strPacketSize )
  93.             
  94.                 if( TRUE = g_objPluginAdmin.DefaultPacketSize ) then
  95.                     g_objPluginAdmin.DefaultPacketSize = FALSE
  96.                 end if
  97.        
  98.                 if( g_dwCustomPacketSize <> g_objPluginAdmin.MaximumPacketSize ) then
  99.                     if( ( MIN_PACKET_SIZE <= g_dwCustomPacketSize ) and ( MAX_PACKET_SIZE >= g_dwCustomPacketSize ) ) then
  100.                         g_objPluginAdmin.MaximumPacketSize = g_dwCustomPacketSize
  101.                     end if
  102.                     if( ErrorDetected( "customSize" ) ) then
  103.                         err.description = RemoveDangerousCharacters( L_UCASTSINKERR_TEXT )
  104.                         bError = TRUE
  105.                         Exit Do
  106.                     end if
  107.                 end if
  108.             end if
  109.         end if
  110.  
  111.         Session( "PageReloadedToDisplayError" ) = 0
  112.  
  113.     Loop Until TRUE
  114.     
  115.     if( bError ) then
  116.         Session( "PageReloadedToDisplayError" ) = 1
  117.     else
  118.         Response.Redirect "../server_props.asp?server=" & g_strQueryStringServer & "&category=" & g_strCategory & "&pluginIndex=" & qs("pluginIndex")
  119.     end if
  120.  
  121. end if
  122.  
  123. g_bUseUDP  = g_objPluginAdmin.UDPEnabled
  124. g_bUseTCP  = g_objPluginAdmin.TCPEnabled
  125. g_bUseCustomPacketSize = CBool( FALSE = g_objPluginAdmin.DefaultPacketSize )
  126. g_dwCustomPacketSize = g_objPluginAdmin.MaximumPacketSize
  127.  
  128. Dim bFromScope
  129. bFromScope = ( "fromScope" = GetFormStr( "ip" ) ) or ( "" = GetFormStr( "ip" ) )
  130.  
  131. WriteHTMLHeader( g_strDecodedServerName ) 
  132. %>
  133. <link rel="stylesheet" type="text/css" href="<%= Session( "cssName" ) %>">
  134. <% WritePluginJSUtils %>
  135. <script language="javascript">
  136. <!--
  137. /*@cc_on @*/
  138. var g_bUserAlertedToNaNEntry = false;
  139. var g_bUserAlertedToOutOfRangeEntry = false;
  140.  
  141. ////////////////////////////////////////////////////////////////  
  142. function EnableRTPOptions()
  143. {
  144.     <% jsTRY %>
  145.     var bUDP = document.forms.pluginForm.UDP.checked;
  146.     
  147.     document.all.packetsizehelp.disabled = ! bUDP;
  148.     document.all.defaultRadio.disabled = ! bUDP;
  149.     document.all.customRadio.disabled = ! bUDP;
  150.     document.forms.pluginForm.packetsize[0].disabled = ! bUDP;
  151.     document.forms.pluginForm.packetsize[1].disabled = ! bUDP;
  152.  
  153.     if( ! bUDP )
  154.     {
  155.         document.forms.pluginForm.customPacketSize.disabled = true;
  156.     }
  157.     else
  158.     {
  159.         document.forms.pluginForm.customPacketSize.disabled = ! document.forms.pluginForm.packetsize[1].checked;
  160.     }
  161.     <% jsCATCH %>
  162. }
  163.  
  164. ////////////////////////////////////////////////////////////////  
  165. function TogglePacketSize( dwWhichRadioButton )
  166. {
  167.     <% jsTRY %>
  168.     document.forms.pluginForm.packetsize[0].checked = ( 0 == dwWhichRadioButton );
  169.     document.forms.pluginForm.packetsize[1].checked = ( 0 != dwWhichRadioButton );
  170.  
  171.     document.forms.pluginForm.customPacketSize.disabled = ( 0 == dwWhichRadioButton );
  172.     
  173.     ValidatePacketSize();
  174.     <% jsCATCH %>
  175. }
  176.  
  177. ////////////////////////////////////////////////////////////////  
  178. function ValidatePacketSize()
  179. {
  180.     <% jsTRY %>
  181.     var szPacketSize;
  182.     var dwPacketSize;
  183.  
  184.     if( document.forms.pluginForm.packetsize[0].checked )
  185.     {
  186.         document.forms.pluginForm.ok.disabled = false;
  187.         return;
  188.     }
  189.     
  190.     szPacketSize = new String( document.forms.pluginForm.customPacketSize.value );
  191.     if( 0 == szPacketSize.length )
  192.     {
  193.         document.forms.pluginForm.customPacketSize.style.color="#ff0000";
  194.         document.forms.pluginForm.ok.disabled = true;
  195.         return;
  196.     }
  197.  
  198.     var regExpTest = new RegExp( /^\d+$/gi );
  199.     if( ! regExpTest.test( szPacketSize ) )
  200.     {
  201.         document.forms.pluginForm.customPacketSize.style.color="#ff0000";
  202.         document.forms.pluginForm.ok.disabled = true;
  203.         if( false == g_bUserAlertedToNaNEntry )
  204.         {
  205.             g_bUserAlertedToNaNEntry = true;
  206.             window.alert( "<%= RemoveDangerousCharacters( L_INVALIDENTRY_TEXT ) %>" );
  207.         }
  208.         return;
  209.     }
  210.     
  211.     dwPacketSize = new Number( szPacketSize );
  212.     if( ( dwPacketSize > <%= Server.HTMLEncode( MAX_PACKET_SIZE ) %> ) || ( dwPacketSize < <%= Server.HTMLEncode( MIN_PACKET_SIZE ) %> ) )
  213.     {
  214.         document.forms.pluginForm.customPacketSize.style.color="#ff0000";
  215.         document.forms.pluginForm.ok.disabled = true;
  216.         if( ( false == g_bUserAlertedToOutOfRangeEntry ) && ( dwPacketSize > <%= Server.HTMLEncode( MAX_PACKET_SIZE ) %> ) )
  217.         {
  218.             window.alert( "<%= RemoveDangerousCharacters( L_INVALIDPKTENTRY_TEXT ) %>" );
  219.             g_bUserAlertedToOutOfRangeEntry = true;
  220.         }
  221.         else
  222.         {
  223.             window.status = "<%= RemoveDangerousCharacters( L_INVALIDPKTENTRY_TEXT ) %>";
  224.         }
  225.         return;
  226.     }
  227.     
  228.     window.status = "";
  229.     document.forms.pluginForm.customPacketSize.style.color="#000000";
  230.     document.forms.pluginForm.ok.disabled = false;  
  231.     <% jsCATCH %>
  232. }
  233. -->
  234. </script>
  235. </head>
  236. <body class="pluginBody" onLoad="JavaScript:g_bUserAlertedToNaNEntry=false;g_bUserAlertedToOutOfRangeEntry=false;EnableRTPOptions();" oncontextmenu="JavaScript:event.cancelBubble=true;return false;">
  237. <% DrawPluginBanner %>
  238. <table width="<%= Server.HTMLEncode( STDTABLEWIDTH ) %>" cellpadding="0" cellspacing="0" border="0">
  239. <tr>
  240.     <td valign=top>
  241.  
  242.         <% WriteStdPluginForm %>
  243.  
  244.         <table class="propgroupbox" border=1 cellspacing=0 cellpadding=0 width=80%>
  245.         <caption align="left" class="pluginGroupHeader"><%= Server.HTMLEncode( L_PROTGROUP_TEXT ) %></caption>
  246.         <tr>
  247.             <td>
  248.                 <table border=0 cellspacing=0 cellpadding=0>
  249.                 <tr>
  250.                     <td colspan=2>
  251.                         <p> 
  252.                         <div class=helptext>
  253.                          <%= Server.HTMLEncode( L_UCASTSINKHELPUE_TEXT ) %>
  254.                         </div>
  255.                     </td>
  256.                 </tr>
  257.                 </table>
  258.                 <table border=0 cellspacing=1 cellpadding=1>
  259.                 <tr>
  260.                     <td>
  261.                          
  262.                     </td>
  263.                     <td>
  264.                          
  265.                     </td>
  266.                     <td align="left">
  267.                         <input 
  268.                             type="checkbox" 
  269.                             name="TCP" 
  270.                             id="TCPCheckbox"
  271.                             tabindex=2 <% if g_bUseTCP then %> checked <% end if %>><label for="TCPCheckbox" class="handcursor"> <%= Server.HTMLEncode( L_TCPCHECKBOX_TEXT ) %></label>
  272.                     </td>
  273.                 </tr>
  274.                 <tr>
  275.                     <td>
  276.                          
  277.                     </td>
  278.                     <td>
  279.                          
  280.                     </td>
  281.                     <td align="left">
  282.                         <input 
  283.                             type="checkbox" 
  284.                             name="UDP" 
  285.                             id="UDPCheckbox"
  286.                             onClick="JavaScript:EnableRTPOptions();"
  287.                             tabindex=1 <% if g_bUseUDP then %> checked <% end if %>><label for="UDPCheckbox" class="handcursor"> <%= Server.HTMLEncode( L_UDPCHECKBOX_TEXT ) %></label>
  288.                         <br>
  289.                     </td>
  290.                 </tr>
  291.                 <tr>
  292.                     <td>
  293.                          
  294.                     </td>
  295.                     <td>
  296.                          
  297.                     </td>
  298.                     <td>
  299.                         <table>
  300.                         <tr>
  301.                             <td>
  302.                                  
  303.                             </td>
  304.                             <td>
  305.                                 <span id="packetsizehelp" class="helptext"><%= Server.HTMLEncode( L_IPPKTSIZEGROUP_TEXT ) %></span>
  306.                             </td>
  307.                         </tr>
  308.                         <tr>
  309.                             <td width="32">
  310.                                  
  311.                             </td>
  312.                             <td>
  313.                             
  314.                                 <table border=0 cellspacing=0 cellpadding=0>
  315.                                 <tr>
  316.                                     <td>
  317.                                         <input 
  318.                                             type="radio" 
  319.                                             id="radio1"
  320.                                             name="packetsize" 
  321.                                             value=0
  322.                                             tabindex=3 <%
  323.                                             if FALSE = g_bUseCustomPacketSize then %> checked <% end if %>
  324.                                             onClick="JavaScript:TogglePacketSize( 0 );"
  325.                                         ><label for="radio1" id="defaultRadio" class="handcursor"> <%= Server.HTMLEncode( L_DEFPKTSIZECHKBOX_TEXT ) %></label>
  326.                                         <br>
  327.                                         <input 
  328.                                             type="radio" 
  329.                                             id="radio2"
  330.                                             name="packetsize" 
  331.                                             value=1
  332.                                             tabindex=4 <%
  333.                                             if g_bUseCustomPacketSize then %> checked <% end if %>
  334.                                             onClick="JavaScript:TogglePacketSize( 1 );"
  335.                                         ><label for="radio2" id="customRadio" class="handcursor"> <% RenderWithErrorCheck Server.HTMLEncode( L_CUSPKTSIZECHKBOX_TEXT ), "customSize" %></label>
  336.                                           <input 
  337.                                                         type="text" 
  338.                                                         name="customPacketSize" 
  339.                                                         onKeyUp="JavaScript:ValidatePacketSize();"
  340.                                                         onKeyDown="JavaScript:ValidatePacketSize();"
  341.                                                         onChange="JavaScript:ValidatePacketSize();"
  342.                                                         onPaste="JavaScript:ValidatePacketSize();"
  343.                                                         tabindex=5 
  344.                                                         maxlength="<%= Server.HTMLEncode( MAX_PACKET_ENTRY_LEN ) %>"
  345.                                                         value="<%= Server.HTMLEncode( g_dwCustomPacketSize ) %>" <% if FALSE = g_bUseCustomPacketSize then %> disabled <% end if %> >
  346.                                         <br>
  347.                                     </td>
  348.                                 </tr>
  349.                                 </table>
  350.                             
  351.                             </td>
  352.                         </tr>
  353.                         </table>
  354.                     </td>
  355.                 </tr>
  356.                 </table>
  357.             </td>
  358.         </tr>
  359.         </table>
  360.     </td>
  361. </tr>
  362. <tr>
  363.     <td>
  364.          <br> 
  365.     </td>
  366. </tr>
  367. <tr>
  368.     <td>
  369.         <tr>
  370.             <td valign=bottom>
  371.                 <input type="submit" name="ok" id="ok" align=baseline tabIndex=5 value="<%= Server.HTMLEncode( L_OKAYBUTTON_TEXT ) %>"> 
  372.                 <input type="button" name="cancel" align=baseline onclick="JavaScript:Cancel();" tabIndex=6 value="<%= Server.HTMLEncode( L_CANCELBUTTONSPACED_TEXT ) %>"> 
  373.                 <input type="button" name="help" onclick="JavaScript:DoPluginHelp( '<%= H_UNICASTSINKHELPTOPIC %>' )" value="<%= Server.HTMLEncode( L_HELPBUTTONSPACED_TEXT ) %>" id=help tabindex=7>
  374.             </td>
  375.         </tr>
  376.     </td>
  377. </tr>
  378. </form>
  379. </table>
  380. <% 
  381. AlertUserWithPopupErrorDialog
  382. OnErrorGoBack 
  383. DrawStdFooter
  384. %>
  385. </body>
  386. </html>
  387. <%
  388. LatchCurrentPage "plugins/UnicastSink.asp", qs
  389. EndErrorHandling "UnicastSink.asp" 
  390.  
  391. on error resume next
  392. PluginsASPCleanup
  393. %>